<template>
	<view class="mine_cont">		
	  <view class="status_bar">
		  <!-- 这里是状态栏 -->
	  </view>
		<uni-nav-bar left-icon="back" right-icon="trash" title="消息详情" @clickLeft="goBack" @clickRight="doDelete"></uni-nav-bar>
		<scroll-view :scroll-top="scrollTop" scroll-y="true" @scrolltoupper="upper" @scrolltolower="lower" @scroll="scroll">
			<view class="list_wrap">
				<view class="list">
					<view class="list_title clearfix">
						<text class="list_title_l">{{newsInfo.bTitle}}</text>
						<text class="list_title_r">{{newsInfo.bDate}}</text>
					</view>
					<view class="list_cont">
						<text>{{newsInfo.bContent}}</text>
					</view>
					
					
					<view class="list_cont addborder" v-if="newsInfo.bType == 2">
						<text>{{newsInfo.bRcontent || '暂未回复'}}</text>
					</view>
					
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>

	import uniNavBar from "@/components/uni-nav-bar/uni-nav-bar.vue"


	export default {
		data() {
			return {
				old: {
					scrollTop: 0
				},
				id:0,
				scrollTop: 0,
				newsInfo: [],
			
			}
		},
		components: {
			uniNavBar
		},
		
		onLoad:function(e){
			 this.id = e.id;
			this.getInfo();
			
		},
		
		
		onLaunch: function() {
			uni.getSystemInfo({
				success: function(e) {
					Vue.prototype.statusBar = e.statusBarHeight
					// #ifndef MP
					if (e.platform == 'android') {
						Vue.prototype.customBar = e.statusBarHeight + 50
					} else {
						Vue.prototype.customBar = e.statusBarHeight + 45
					}
					// #endif

					// #ifdef MP-WEIXIN
					let custom = wx.getMenuButtonBoundingClientRect()
					Vue.prototype.customBar = custom.bottom + custom.top - e.statusBarHeight
					// #endif

					// #ifdef MP-ALIPAY
					Vue.prototype.customBar = e.statusBarHeight + e.titleBarHeight
					// #endif
				}
			})
		},
		mounted() {
			//this.newsInfo = info.newsInfo;
		
		},
		methods: {
			upper: function(e) {
				// console.log(e)
			},
			lower: function(e) {
				// console.log(e)
			},
			scroll: function(e) {
				this.old.scrollTop = e.detail.scrollTop
			},
			
			getInfo: function(){
				this.$api.http
					.get('assistance/books/lookBooks', {
						id: this.id
					})
					.then(res => {
						this.newsInfo = res.data;
					});
				
			},
			
			
			goBack() {
				// uni.navigateTo({
				// 	url: "./news"
				// })
				uni.navigateBack()
			},
			doDelete() {
				var that = this;
				uni.showModal({
					title: '提示',
					content: '确认要删除？',
					success: function(res) {
						if (res.confirm) {
							
							that.$api.http
								.post('assistance/books/deleteBooks', {
									id: that.id
								})
								.then(res => {
									uni.$emit('deleteinfo',that.id);
									that.goBack();
									//this.newsInfo = res.data;
								});
							
							//console.log('用户点击确定');
						} else if (res.cancel) {
						//	console.log('用户点击取消');
						}
					}
				});
			}
		}
	}
</script>


<style lang="scss">
	.clearfix {
		zoom: 1;
		display: block;
	}
	
	.addborder{
			  padding-top:10upx;
			  border-top: 2upx solid #f4f5f7;
	}

	.clearfix:after {
		content: ".";
		visibility: hidden;
		display: block;
		height: 0;
		clear: both;
	}

	scroll-view {
		height: 100vh;
	}
	 .status_bar {
		  height: var(--status-bar-height);
		  width: 100%;
		  background-color: #FFFFFF;
	  }
	.mine_cont {
		background-color: #f4f5f7;
		width: 100%;
		height: 100vh;

		.list_wrap {

			.list {
				margin: 30upx;
				padding: 30upx;
				background-color: #ffffff;

				.list_title {
					height: 46upx;
					line-height: 30upx;
					border-bottom: 2upx solid #f4f5f7;

					.list_title_l {
						font-size: 28upx;
						width: 56%;
						overflow: hidden;
						text-overflow: ellipsis;
						display: inline-block;
						white-space: nowrap;
						float: left;
					}

					.list_title_r {
						float: right;
						font-size: 24upx;
						line-height: 30upx;
						color: #636564;
					}
				}

				.list_cont {
					margin-top: 10upx;
					color: #6f6f6f;
					font-size: 26upx;
					text-align: left;
					line-height: 42upx;
				}
			}
		}
	}
</style>
